package com.wjw.compositereuse.reuse02;

/**
 * TODO: 描述
 *
 * @author ikaros
 * @date 2024/7/17 1:08
 * @see <a href="ikaros@qq.com">mailTo: ikaros@qq.com</a>
 */
public class Car {

    public static void main(String[] args) {
        Car car = new Car();
        car.setColor(new Green());
        car.setEnergy(new Electric());
        car.outCar();
    }

    /**
     * 能源
     */
    private Energy energy;
    /**
     * 颜色
     */
    private Color color;

    public Energy getEnergy() {
        return energy;
    }

    public void setEnergy(Energy energy) {
        this.energy = energy;
    }

    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public void outCar(){
        System.out.println(color.getColor() + energy.getEnergy() + "车");
    }
}
